package stream;

import lambda.Employee;

import java.util.Optional;

/**
 * @author shentianyu
 * @date 2021-06-25 20:54
 */
public class TestOptional {
    public static void main(String[] args) {
//        Optional<Employee> optionalEmployee = Optional.of(new Employee());
//        Employee employee = optionalEmployee.get();
//        System.out.println(employee);
//
//        Optional<Object> empty = Optional.empty();
//        System.out.println(empty);
//
//        Optional<Object> o = Optional.ofNullable(new Employee());
//        System.out.println(o);

        Optional<Object> optional = Optional.ofNullable(new Employee());
        Object o1 = optional.orElse(new Employee("张三", 20, 2000.0, Employee.Status.BUSY));
        System.out.println(o1);


        Object o = optional.orElseGet(() -> {
            //各种功能
            return new Employee();
        });

    }
}
